package com.czy.owner.adapter;

import android.content.Context;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.load.resource.drawable.GlideDrawable;
import com.czy.owner.R;
import com.czy.owner.entity.FindActivityModel;
import com.czy.owner.entity.GuessYouLikeModel;
import com.czy.owner.utils.TimeUtils;
import com.czy.owner.utils.glide.GlideUtils;
import com.easyrecycleview.adapter.BaseViewHolder;
import com.easyrecycleview.adapter.RecyclerArrayAdapter;


/**
 * Created by wangyang on 2017/5/15 0015.
 */

public class ShoppingLikeAapter extends RecyclerArrayAdapter<GuessYouLikeModel.ListBean> {
    private Context context;

    public ShoppingLikeAapter(Context context) {
        super(context);
        this.context = context;
    }

    @Override
    public BaseViewHolder OnCreateViewHolder(ViewGroup parent, int viewType) {
        return new ShoppingLikeViewHolder(parent, context);
    }

    class ShoppingLikeViewHolder extends BaseViewHolder<GuessYouLikeModel.ListBean> {

        private ImageView imgShoppingLike;
        private TextView tvShoppingLikeTitle;
        private TextView tvShoppingLikePayment;

        public ShoppingLikeViewHolder(ViewGroup parent, Context ctx) {
            super(parent, R.layout.item_shopping_like);
            imgShoppingLike = $(R.id.img_shopping_like);
            tvShoppingLikeTitle = $(R.id.tv_shopping_like_title);
            tvShoppingLikePayment = $(R.id.tv_shopping_like_payment);
        }

        @Override
        public void setData(GuessYouLikeModel.ListBean data) {
            super.setData(data);
            tvShoppingLikeTitle.setText(data.getGoodsName());
            tvShoppingLikePayment.setText("￥"+String.format("%.2f",data.getPrice()));
                GlideUtils.loadImage(context, data.getGoodsLogo(), imgShoppingLike, new GlideUtils.ImageLoadListener<String, GlideDrawable>() {
                    @Override
                    public void onLoadingComplete(String uri, ImageView view, GlideDrawable resource) {

                    }

                    @Override
                    public void onLoadingError(String source, Exception e) {

                    }
                }, R.mipmap.default_icon, R.mipmap.default_icon);

        }
    }
}
